package com.alex.springdata.service;

import com.alex.springdata.entity.Person;
import com.alex.springdata.repository.PersonCrudRepository;
import com.alex.springdata.repository.PersonRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class PersonService {

    @Resource
    private PersonRepository repository;

    @Resource
    private PersonCrudRepository crudRepository;

    public Person getByLastName(String lastName) {
        return repository.getByLastName(lastName);
    }

    public void updatePersonEmail(Integer id, String email) {
        repository.updatePersonEmail(id, email);
    }

    public void savePerson(Person person) {
        crudRepository.save(person);
    }

}
